#include "Core/wxResourceHelper.h"

wxImage loadImageFromResourceZip(wxString filename, long type)
{
	wxImage img;
	{
#ifdef __WXMSW__
		wxString path = wxT("file://OgreMeshToolResources.zip#zip:") + (filename);
#else
		wxString path = wxT("file://") + wxGetCwd() + wxFILE_SEP_PATH + wxT("OgreMeshToolResources.zip#zip:") + (filename);
#endif // __WXMSW__
		wxFileSystem filesystem;
		wxFSFile *file = filesystem.OpenFile(path, wxFS_READ|wxFS_SEEKABLE);
		if(!file)
		{
			wxMessageBox( wxT( "unable to load resource: " + path  ), wxT("error"), wxOK|wxICON_WARNING|wxCENTRE );
			return wxNullImage;
		}
		img.LoadFile(*file->GetStream(), type);

		delete(file);
		file = NULL;
	}

	return img;
}

wxIcon createIconFromResourceImage(wxString filename, long type)
{
	wxImage img = loadImageFromResourceZip( filename, type);
	wxIcon ico;
	ico.CopyFromBitmap(img);
	return ico;
}
